/**
 * [formatDateWithTimeZone 格式化日期带时区，ISO 8601]
 * @param  {[Date]} date [日期，非必填参数，表示调用时的时间]
 * @return {[String]}     [ISO 8601格式的日期，example: 2016-11-21T14:09:15+08:00]
 */
export function formatDateWithTimeZone(date) {

    date = date ? date : new Date();
    if (!(date instanceof Date)) {
        if (date.indexOf('-') != -1) {
            date.replace(/\-/g, '/');
        }
        date = new Date(date);
    }

    let tzo = -date.getTimezoneOffset(),
        dif = tzo >= 0 ? '+' : '-',
        pad = function (num) {
            let norm = Math.abs(Math.floor(num));
            return zeroPadding(norm);
        };
    return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())}T${pad(date.getHours())}:${pad(date.getMinutes())}:${pad(date.getSeconds())}${dif}${pad(tzo / 60)}:${pad(tzo % 60)}`;

}
